<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">

        //定义变量
    var a=1;
    var b='sss';
     alert(a+b);//+连接字符串和非字符串时，还是做连接符用。
    var c="a";
    a=b;

    var obja={name:"小王",age:30}
    //    console.log(obja);
    var obj=new Object();
    //console.log(obj.get("name"));

    //方法
    function  getDate() {
        console.log(Date());
    }


    var txt1=document.getElementById("txt1")//通过元素的id来获取一个元素
    //   console.log(document.getElementById("txt1"));

    //    document.getElementById("txt1")
    var arr1=document.getElementsByName("txt1");
    //    console.log(arr1.length);//通过元素的name来获取一个数组


</script>
<input type="button" value="获取时间" onclick="getDate()"><br>
<input type="text" id="txt1" value="aa ">
<input type="text" name="txt1" value="b ">
<input type="text" name="txt1" value="c ">
<input type="button" value="修改文本" onclick="setTxt1()"><br>
<script>

    var txt2=document.getElementById("txt1")//通过元素的id来获取一个元素
    //    console.log(document.getElementById("txt1").value);
    function getTxt1() {
        console.log(document.getElementById("txt1").value);
    }
    function setTxt1() {
        document.getElementById("txt1").value='99999999';
    }
    function addT(a,b) {
        return a+b;
    }
    //    console.log(addT(1,2));
    var result=100;
    function foradd(a,b) {

        if(a==3){
            result=3 ;
        }else{
            result=a;
            for(var i=a;i<a+b;i++){
//                console.log(i);
                result=result+1;
            }
        }
        return result;


    }
    console.log(foradd(1,3));
    console.log(result);


    var arr1=document.getElementsByName("txt1");
    console.log(arr1[0].innerHTML);//innerHTML是用来获取网页元素的网页内容（非自身属性）

    var myjava=new Array();
    myjava[0]="spring";
    myjava[1]="struts";
    myjava[2]="hibernate";
    console.log(myjava);
    var myjava=new Array("a","b","c");
    var myjava=["a","b","c"];
    console.log(myjava.indexOf("b"));

</script>
<input type="password" name="inpwd">
<input type="password" name="inpwd">
<script>

    console.log(document.getElementsByName("xd")[0].innerHTML)
    console.log(form1.inTxt.value);
    function sub() {
        var user= document.getElementsByName("inTxt")[0].value;
        if(user.length==0||user.length>20){
            alert("请输入正确的帐号");
            return;
        }else if(document.getElementsByName("inPwd")[0].value!=document.getElementsByName("inPwd")[1].value){
            alert("两次输入密码不同");
            return;
        }
        document.getElementById("form1").submit();
    }
</script>
</body>
</html>
